1,json类型1
var data = [
{
"id":"1",
"url":"https://api.server.com/server/sc/area/getOpenAreas",
"param":""
},
{
"id":"2",
"url":"https://api.server.com/server/sc/blackList/updateBlackList",
"userType":"1",
"userId":"12",
"targetId":"1000001"
},
{
"id":"3",
"url":"https://api.server.com/server/sc/commodity/getCommodity",
"shopId":"11111111",
"page":"",
"limit":"100"
}
]
$scope.setApi = function(data){
var _object = $filter('filter')(data[0]);//取出id为1的json对象
console.log("----------------_object---------------")
console.log(_object)
//[object,object...]
var s_object = $filter('filter')(_object.url);//[5] 比如说可以取对象里面url中的第5个字符,去掉就可以取出全部的url
console.log("---------------s_object-------------")
console.log(s_object)
//https://api.server.com/server/sc/area/getOpenAreas
}
2,json类型2
var data = { "results": [
{
"id": 1,
"name": "mikeTest"
},
{
"id": 2,
"name": "mikeTest2"
},
{
"id": 3,
"name": "mikeTest"
}
] }
var _object = $filter('filter')(data.results, function (i) {return i.id === 2;})[0];
console.log(_object);
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。